/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JInternalFrameStock.java
 *
 * Created on Dec 10, 2011, 9:50:05 PM
 */
package callcenter;

import Database.*;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

/**
 *
 * @author user
 */
public class JInternalFrameStock extends javax.swing.JInternalFrame {

    private boolean flag, flag1, flag2 = true;
    private DefaultMutableTreeNode nutgoc = new DefaultMutableTreeNode("Product");
    private DefaultMutableTreeNode SanPham11 = new DefaultMutableTreeNode();
    private DefaultMutableTreeNode sp11 = new DefaultMutableTreeNode();
    private JPanel jPanel4;

    /** Creates new form JInternalFrameStock */
    public JInternalFrameStock() {
        initComponents();
        LoadDate();
        DienSanPham();
        Month();
        Jtree();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel42 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jPanel41 = new javax.swing.JPanel();
        jPanel23 = new javax.swing.JPanel();
        jPanel16 = new javax.swing.JPanel();
        jPanel22 = new javax.swing.JPanel();
        jPanel20 = new javax.swing.JPanel();
        jPanel17 = new javax.swing.JPanel();
        jPanel18 = new javax.swing.JPanel();
        jPanel19 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jPanel21 = new javax.swing.JPanel();
        jLabeltotalProduct = new javax.swing.JLabel();
        jPanel40 = new javax.swing.JPanel();
        jPanel28 = new javax.swing.JPanel();
        jPanel26 = new javax.swing.JPanel();
        jPanel24 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel25 = new javax.swing.JPanel();
        jCalendarPopup1 = new org.sourceforge.jcalendarbutton.JCalendarPopup();
        jComboBoxTotal = new javax.swing.JComboBox();
        jPanel27 = new javax.swing.JPanel();
        jPanel39 = new javax.swing.JPanel();
        jPanel37 = new javax.swing.JPanel();
        jPanel29 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jPanel36 = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();
        jPanel38 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jPanel85 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jPanel67 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jPanel80 = new javax.swing.JPanel();
        jPanel68 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTreeProduct = new javax.swing.JTree();
        jPanel79 = new javax.swing.JPanel();
        jPanel71 = new javax.swing.JPanel();
        jPanel69 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBoxMotnh = new javax.swing.JComboBox();
        jPanel70 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jComboBoxSelectTime = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jComboBoxProduct = new javax.swing.JComboBox();
        jPanel78 = new javax.swing.JPanel();
        jPanel76 = new javax.swing.JPanel();
        jPanel72 = new javax.swing.JPanel();
        jPanel73 = new javax.swing.JPanel();
        jButtonPurchar = new javax.swing.JButton();
        jPanel74 = new javax.swing.JPanel();
        jButtonsale = new javax.swing.JButton();
        jPanel75 = new javax.swing.JPanel();
        jPanel77 = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        jLabelsl = new javax.swing.JLabel();
        jPanel84 = new javax.swing.JPanel();
        jPanel82 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel81 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jPanel13 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jPanel83 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableHS = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jLabelSql = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(970, 520));

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(callcenter.CallcenterApp.class).getContext().getResourceMap(JInternalFrameStock.class);
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel1.border.lineColor"), 2)); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(930, 120));

        jPanel42.setName("jPanel42"); // NOI18N
        jPanel42.setPreferredSize(new java.awt.Dimension(897, 110));
        jPanel42.setLayout(new java.awt.BorderLayout());

        jPanel7.setName("jPanel7"); // NOI18N

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );

        jPanel42.add(jPanel7, java.awt.BorderLayout.LINE_END);

        jPanel15.setName("jPanel15"); // NOI18N

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );

        jPanel42.add(jPanel15, java.awt.BorderLayout.LINE_START);

        jPanel41.setName("jPanel41"); // NOI18N
        jPanel41.setLayout(new java.awt.BorderLayout());

        jPanel23.setName("jPanel23"); // NOI18N
        jPanel23.setPreferredSize(new java.awt.Dimension(300, 102));
        jPanel23.setLayout(new java.awt.BorderLayout());

        jPanel16.setName("jPanel16"); // NOI18N
        jPanel16.setPreferredSize(new java.awt.Dimension(50, 102));

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 50, Short.MAX_VALUE)
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );

        jPanel23.add(jPanel16, java.awt.BorderLayout.LINE_END);

        jPanel22.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel22.border.border.lineColor")), resourceMap.getString("jPanel22.border.title"))); // NOI18N
        jPanel22.setName("jPanel22"); // NOI18N
        jPanel22.setLayout(new java.awt.GridLayout(2, 1, 2, 2));

        jPanel20.setName("jPanel20"); // NOI18N
        jPanel20.setLayout(new java.awt.BorderLayout());

        jPanel17.setName("jPanel17"); // NOI18N
        jPanel17.setPreferredSize(new java.awt.Dimension(70, 50));

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 70, Short.MAX_VALUE)
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 43, Short.MAX_VALUE)
        );

        jPanel20.add(jPanel17, java.awt.BorderLayout.LINE_START);

        jPanel18.setName("jPanel18"); // NOI18N
        jPanel18.setPreferredSize(new java.awt.Dimension(70, 50));

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 70, Short.MAX_VALUE)
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 43, Short.MAX_VALUE)
        );

        jPanel20.add(jPanel18, java.awt.BorderLayout.LINE_END);

        jPanel19.setName("jPanel19"); // NOI18N
        jPanel19.setLayout(new java.awt.BorderLayout());

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel19.add(jButton1, java.awt.BorderLayout.PAGE_START);

        jPanel20.add(jPanel19, java.awt.BorderLayout.CENTER);

        jPanel22.add(jPanel20);

        jPanel21.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel21.border.lineColor"))); // NOI18N
        jPanel21.setName("jPanel21"); // NOI18N
        jPanel21.setLayout(new java.awt.BorderLayout());

        jLabeltotalProduct.setBackground(resourceMap.getColor("jLabeltotalProduct.background")); // NOI18N
        jLabeltotalProduct.setFont(resourceMap.getFont("jLabeltotalProduct.font")); // NOI18N
        jLabeltotalProduct.setForeground(resourceMap.getColor("jLabeltotalProduct.foreground")); // NOI18N
        jLabeltotalProduct.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabeltotalProduct.setText(resourceMap.getString("jLabeltotalProduct.text")); // NOI18N
        jLabeltotalProduct.setName("jLabeltotalProduct"); // NOI18N
        jPanel21.add(jLabeltotalProduct, java.awt.BorderLayout.CENTER);

        jPanel22.add(jPanel21);

        jPanel23.add(jPanel22, java.awt.BorderLayout.CENTER);

        jPanel41.add(jPanel23, java.awt.BorderLayout.LINE_START);

        jPanel40.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel40.border.border.lineColor")), resourceMap.getString("jPanel40.border.title"))); // NOI18N
        jPanel40.setName("jPanel40"); // NOI18N
        jPanel40.setLayout(new java.awt.GridLayout(2, 1));

        jPanel28.setName("jPanel28"); // NOI18N
        jPanel28.setLayout(new java.awt.GridLayout(2, 1));

        jPanel26.setName("jPanel26"); // NOI18N
        jPanel26.setLayout(new java.awt.BorderLayout());

        jPanel24.setName("jPanel24"); // NOI18N
        jPanel24.setPreferredSize(new java.awt.Dimension(110, 25));
        jPanel24.setLayout(new java.awt.BorderLayout());

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel24.add(jLabel2, java.awt.BorderLayout.CENTER);

        jPanel26.add(jPanel24, java.awt.BorderLayout.LINE_START);

        jPanel25.setName("jPanel25"); // NOI18N
        jPanel25.setLayout(new java.awt.BorderLayout());
        jCalendarPopup1.setName("jCalendarPopup1"); // NOI18N
        jCalendarPopup1.setLayout(new java.awt.BorderLayout());

        jComboBoxTotal.setName("jComboBoxTotal"); // NOI18N
        jCalendarPopup1.add(jComboBoxTotal, java.awt.BorderLayout.CENTER);

        jPanel25.add(jCalendarPopup1, java.awt.BorderLayout.CENTER);

        jPanel26.add(jPanel25, java.awt.BorderLayout.CENTER);

        jPanel28.add(jPanel26);

        jPanel27.setName("jPanel27"); // NOI18N

        javax.swing.GroupLayout jPanel27Layout = new javax.swing.GroupLayout(jPanel27);
        jPanel27.setLayout(jPanel27Layout);
        jPanel27Layout.setHorizontalGroup(
            jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 387, Short.MAX_VALUE)
        );
        jPanel27Layout.setVerticalGroup(
            jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 22, Short.MAX_VALUE)
        );

        jPanel28.add(jPanel27);

        jPanel40.add(jPanel28);

        jPanel39.setName("jPanel39"); // NOI18N
        jPanel39.setLayout(new java.awt.BorderLayout());

        jPanel37.setName("jPanel37"); // NOI18N
        jPanel37.setPreferredSize(new java.awt.Dimension(110, 51));
        jPanel37.setLayout(new java.awt.GridLayout(2, 1));

        jPanel29.setName("jPanel29"); // NOI18N
        jPanel29.setLayout(new java.awt.BorderLayout());

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jPanel29.add(jButton2, java.awt.BorderLayout.CENTER);

        jPanel37.add(jPanel29);

        jPanel36.setName("jPanel36"); // NOI18N
        jPanel36.setLayout(new java.awt.BorderLayout());

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jPanel36.add(jButton3, java.awt.BorderLayout.CENTER);

        jPanel37.add(jPanel36);

        jPanel39.add(jPanel37, java.awt.BorderLayout.LINE_START);

        jPanel38.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel38.border.lineColor"))); // NOI18N
        jPanel38.setName("jPanel38"); // NOI18N
        jPanel38.setLayout(new java.awt.BorderLayout());

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N
        jPanel38.add(jLabel3, java.awt.BorderLayout.CENTER);

        jPanel39.add(jPanel38, java.awt.BorderLayout.CENTER);

        jPanel40.add(jPanel39);

        jPanel41.add(jPanel40, java.awt.BorderLayout.CENTER);

        jPanel42.add(jPanel41, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 955, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(0, 29, Short.MAX_VALUE)
                    .addComponent(jPanel42, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 29, Short.MAX_VALUE)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 116, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(0, 3, Short.MAX_VALUE)
                    .addComponent(jPanel42, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 3, Short.MAX_VALUE)))
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.BorderLayout());

        jPanel85.setName("jPanel3"); // NOI18N
        jPanel85.setPreferredSize(new java.awt.Dimension(926, 400));

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel5.border.border.lineColor")), resourceMap.getString("jPanel5.border.title"))); // NOI18N
        jPanel10.setName("jPanel5"); // NOI18N
        jPanel10.setPreferredSize(new java.awt.Dimension(360, 200));
        jPanel10.setLayout(new java.awt.BorderLayout());

        jPanel67.setName("jPanel30"); // NOI18N
        jPanel67.setPreferredSize(new java.awt.Dimension(358, 30));
        jPanel67.setLayout(new java.awt.BorderLayout());

        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel11.setName("jLabel5"); // NOI18N
        jPanel67.add(jLabel11, java.awt.BorderLayout.CENTER);

        jPanel10.add(jPanel67, java.awt.BorderLayout.PAGE_START);

        jPanel80.setName("jPanel31"); // NOI18N
        jPanel80.setLayout(new java.awt.BorderLayout());

        jPanel68.setName("jPanel32"); // NOI18N
        jPanel68.setPreferredSize(new java.awt.Dimension(358, 200));
        jPanel68.setLayout(new java.awt.BorderLayout());

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
        jTreeProduct.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        jTreeProduct.setName("jTreeProduct"); // NOI18N
        jTreeProduct.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTreeProductMouseClicked(evt);
            }
        });
        jTreeProduct.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                jTreeProductValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(jTreeProduct);

        jPanel68.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jPanel80.add(jPanel68, java.awt.BorderLayout.PAGE_START);

        jPanel79.setName("jPanel33"); // NOI18N
        jPanel79.setLayout(new java.awt.BorderLayout());

        jPanel71.setName("jPanel34"); // NOI18N
        jPanel71.setPreferredSize(new java.awt.Dimension(358, 30));
        jPanel71.setLayout(new java.awt.BorderLayout());

        jPanel69.setName("jPanel43"); // NOI18N
        jPanel69.setPreferredSize(new java.awt.Dimension(130, 30));

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jComboBoxMotnh.setName("jComboBoxMotnh"); // NOI18N

        javax.swing.GroupLayout jPanel69Layout = new javax.swing.GroupLayout(jPanel69);
        jPanel69.setLayout(jPanel69Layout);
        jPanel69Layout.setHorizontalGroup(
            jPanel69Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel69Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxMotnh, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel69Layout.setVerticalGroup(
            jPanel69Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel69Layout.createSequentialGroup()
                .addGroup(jPanel69Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
                    .addComponent(jComboBoxMotnh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel71.add(jPanel69, java.awt.BorderLayout.LINE_START);

        jPanel70.setName("jPanel44"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jComboBoxSelectTime.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxSelectTime.setName("jComboBoxSelectTime"); // NOI18N
        jComboBoxSelectTime.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxSelectTimeActionPerformed(evt);
            }
        });

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jComboBoxProduct.setName("jComboBoxProduct"); // NOI18N
        jComboBoxProduct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxProductActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel70Layout = new javax.swing.GroupLayout(jPanel70);
        jPanel70.setLayout(jPanel70Layout);
        jPanel70Layout.setHorizontalGroup(
            jPanel70Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel70Layout.createSequentialGroup()
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxSelectTime, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxProduct, 0, 54, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel70Layout.setVerticalGroup(
            jPanel70Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel70Layout.createSequentialGroup()
                .addGroup(jPanel70Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
                    .addComponent(jComboBoxSelectTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
                    .addComponent(jComboBoxProduct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel71.add(jPanel70, java.awt.BorderLayout.CENTER);

        jPanel79.add(jPanel71, java.awt.BorderLayout.PAGE_START);

        jPanel78.setName("jPanel35"); // NOI18N
        jPanel78.setLayout(new java.awt.BorderLayout());

        jPanel76.setName("jPanel45"); // NOI18N
        jPanel76.setPreferredSize(new java.awt.Dimension(130, 138));
        jPanel76.setLayout(new java.awt.GridLayout(4, 1, 3, 3));

        jPanel72.setName("jPanel47"); // NOI18N

        javax.swing.GroupLayout jPanel72Layout = new javax.swing.GroupLayout(jPanel72);
        jPanel72.setLayout(jPanel72Layout);
        jPanel72Layout.setHorizontalGroup(
            jPanel72Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 130, Short.MAX_VALUE)
        );
        jPanel72Layout.setVerticalGroup(
            jPanel72Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 27, Short.MAX_VALUE)
        );

        jPanel76.add(jPanel72);

        jPanel73.setName("jPanel48"); // NOI18N
        jPanel73.setPreferredSize(new java.awt.Dimension(120, 32));
        jPanel73.setLayout(new java.awt.BorderLayout());

        jButtonPurchar.setText(resourceMap.getString("jButtonPurchar.text")); // NOI18N
        jButtonPurchar.setName("jButtonPurchar"); // NOI18N
        jButtonPurchar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPurcharActionPerformed(evt);
            }
        });
        jPanel73.add(jButtonPurchar, java.awt.BorderLayout.CENTER);

        jPanel76.add(jPanel73);

        jPanel74.setName("jPanel50"); // NOI18N
        jPanel74.setLayout(new java.awt.BorderLayout());

        jButtonsale.setText(resourceMap.getString("jButtonsale.text")); // NOI18N
        jButtonsale.setName("jButtonsale"); // NOI18N
        jButtonsale.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonsaleActionPerformed(evt);
            }
        });
        jPanel74.add(jButtonsale, java.awt.BorderLayout.CENTER);

        jPanel76.add(jPanel74);

        jPanel75.setName("jPanel49"); // NOI18N

        javax.swing.GroupLayout jPanel75Layout = new javax.swing.GroupLayout(jPanel75);
        jPanel75.setLayout(jPanel75Layout);
        jPanel75Layout.setHorizontalGroup(
            jPanel75Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 130, Short.MAX_VALUE)
        );
        jPanel75Layout.setVerticalGroup(
            jPanel75Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 27, Short.MAX_VALUE)
        );

        jPanel76.add(jPanel75);

        jPanel78.add(jPanel76, java.awt.BorderLayout.LINE_START);

        jPanel77.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel46.border.lineColor"))); // NOI18N
        jPanel77.setName("jPanel46"); // NOI18N
        jPanel77.setLayout(new java.awt.BorderLayout());

        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel13.setName("jLabel7"); // NOI18N
        jPanel77.add(jLabel13, java.awt.BorderLayout.PAGE_START);

        jLabelsl.setFont(resourceMap.getFont("jLabel8.font")); // NOI18N
        jLabelsl.setForeground(resourceMap.getColor("jLabel8.foreground")); // NOI18N
        jLabelsl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelsl.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabelsl.setBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jLabel8.border.lineColor"))); // NOI18N
        jLabelsl.setName("jLabel8"); // NOI18N
        jPanel77.add(jLabelsl, java.awt.BorderLayout.CENTER);

        jPanel78.add(jPanel77, java.awt.BorderLayout.CENTER);

        jPanel79.add(jPanel78, java.awt.BorderLayout.CENTER);

        jPanel80.add(jPanel79, java.awt.BorderLayout.CENTER);

        jPanel10.add(jPanel80, java.awt.BorderLayout.CENTER);

        jPanel84.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(resourceMap.getColor("jPanel6.border.border.lineColor")), resourceMap.getString("jPanel6.border.title"))); // NOI18N
        jPanel84.setName("jPanel6"); // NOI18N
        jPanel84.setPreferredSize(new java.awt.Dimension(510, 200));
        jPanel84.setLayout(new java.awt.BorderLayout());

        jPanel82.setName("jPanel8"); // NOI18N
        jPanel82.setPreferredSize(new java.awt.Dimension(448, 30));
        jPanel82.setLayout(new java.awt.BorderLayout());

        jPanel11.setName("jPanel10"); // NOI18N
        jPanel11.setPreferredSize(new java.awt.Dimension(200, 30));
        jPanel11.setLayout(new java.awt.BorderLayout());

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N
        jPanel11.add(jLabel4, java.awt.BorderLayout.CENTER);

        jPanel82.add(jPanel11, java.awt.BorderLayout.LINE_START);

        jPanel81.setName("jPanel11"); // NOI18N
        jPanel81.setLayout(new java.awt.BorderLayout());

        jPanel12.setName("jPanel12"); // NOI18N
        jPanel12.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel12.setLayout(new java.awt.BorderLayout());

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setName("jTextField1"); // NOI18N
        jPanel12.add(jTextField1, java.awt.BorderLayout.CENTER);

        jPanel81.add(jPanel12, java.awt.BorderLayout.LINE_START);

        jPanel13.setName("jPanel13"); // NOI18N
        jPanel13.setLayout(new java.awt.BorderLayout());

        jPanel14.setName("jPanel14"); // NOI18N
        jPanel14.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel14.setLayout(new java.awt.BorderLayout());

        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N
        jPanel14.add(jButton4, java.awt.BorderLayout.CENTER);

        jPanel13.add(jPanel14, java.awt.BorderLayout.LINE_START);

        jPanel81.add(jPanel13, java.awt.BorderLayout.CENTER);

        jPanel82.add(jPanel81, java.awt.BorderLayout.CENTER);

        jPanel84.add(jPanel82, java.awt.BorderLayout.PAGE_START);

        jPanel83.setName("jPanel9"); // NOI18N
        jPanel83.setLayout(new java.awt.BorderLayout());

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setPreferredSize(new java.awt.Dimension(500, 100));
        jPanel4.setLayout(new java.awt.BorderLayout());

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setPreferredSize(new java.awt.Dimension(500, 150));
        jPanel3.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTableHS.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableHS.setName("jTableHS"); // NOI18N
        jScrollPane1.setViewportView(jTableHS);

        jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel4.add(jPanel3, java.awt.BorderLayout.PAGE_START);

        jPanel5.setName("jPanel5"); // NOI18N

        jLabelSql.setFont(resourceMap.getFont("jLabelSql.font")); // NOI18N
        jLabelSql.setForeground(resourceMap.getColor("jLabelSql.foreground")); // NOI18N
        jLabelSql.setText(resourceMap.getString("jLabelSql.text")); // NOI18N
        jLabelSql.setName("jLabelSql"); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addComponent(jLabelSql, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(372, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addComponent(jLabelSql, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(137, Short.MAX_VALUE))
        );

        jPanel4.add(jPanel5, java.awt.BorderLayout.CENTER);

        jPanel83.add(jPanel4, java.awt.BorderLayout.CENTER);

        jPanel84.add(jPanel83, java.awt.BorderLayout.CENTER);

        javax.swing.GroupLayout jPanel85Layout = new javax.swing.GroupLayout(jPanel85);
        jPanel85.setLayout(jPanel85Layout);
        jPanel85Layout.setHorizontalGroup(
            jPanel85Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel85Layout.createSequentialGroup()
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(89, 89, 89)
                .addComponent(jPanel84, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel85Layout.setVerticalGroup(
            jPanel85Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(jPanel84, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel2.add(jPanel85, java.awt.BorderLayout.PAGE_START);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void TotalProduct() {
        jLabeltotalProduct.setText(String.valueOf(Stock.sumProduct()));
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:

        TotalProduct();
    }//GEN-LAST:event_jButton1ActionPerformed
    private void Jtree() {


        for (int i = 0; i < Stock.ListProduct().size(); i++) {
            nutgoc.add(new DefaultMutableTreeNode(Stock.ListProduct().get(i)));
            DefaultTreeModel dtm = new DefaultTreeModel(nutgoc);
            jTreeProduct.setModel(dtm);

        }

    }

    private void LoadDate() {
        Vector vt = new Vector();
        Calendar c = Calendar.getInstance();
        int year = (int) c.get(Calendar.YEAR);
        for (int i = 2005; i <= year; i++) {
            vt.add(i);
            DefaultComboBoxModel dcbm = new DefaultComboBoxModel(vt);
            jComboBoxTotal.setModel(dcbm);
            jComboBoxSelectTime.setModel(dcbm);
        }

    }

    private void Dien() {
        if (flag == true) {
            JOptionPane.showMessageDialog(null, "Please ! select year ");
        } else {
            jLabelsl.setText(String.valueOf(Stock.totalProductPurchar(jComboBoxSelectTime.getSelectedItem().toString(), jComboBoxMotnh.getSelectedItem().toString(), Stock.IdProduct(jComboBoxProduct.getSelectedItem().toString()))));
        }
    }

    private void Month() {
        Vector m = new Vector();
        for (int i = 1; i <= 12; i++) {

            m.add(i);
            DefaultComboBoxModel dcbm = new DefaultComboBoxModel(m);
            jComboBoxMotnh.setModel(dcbm);
        }
    }
    private void jButtonPurcharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPurcharActionPerformed

        Dien();

    }//GEN-LAST:event_jButtonPurcharActionPerformed

    private void DienSanPham() {
        DefaultComboBoxModel dcbm = new DefaultComboBoxModel(Stock.ListProduct());
        jComboBoxProduct.setModel(dcbm);

    }

    private void jButtonsaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonsaleActionPerformed
    }//GEN-LAST:event_jButtonsaleActionPerformed

    private void jComboBoxSelectTimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSelectTimeActionPerformed
        flag = false;



    }//GEN-LAST:event_jComboBoxSelectTimeActionPerformed

    private void jComboBoxProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxProductActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxProductActionPerformed

    private void jTreeProductMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTreeProductMouseClicked
        
        
        
    }//GEN-LAST:event_jTreeProductMouseClicked

    private void DienDuLieuTable(int id)
    {
        Vector v = new Vector();
        v.add("Date");
        v.add("Product name");
        v.add("Vender");
        v.add("Quanlity");
        v.add("Price");
        v.add("Thanh tien");
        DefaultTableModel dtm = new DefaultTableModel(Stock.History(id), v);
        jTableHS.setModel(dtm);
    }
    private void Label(String id , String time)
    {
        int a = Stock.sumProductSales(id, time);
       jLabelSql.setText(String.valueOf(a));
    }
    
    
    private void jTreeProductValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTreeProductValueChanged
        
       DefaultMutableTreeNode cn = (DefaultMutableTreeNode)this.jTreeProduct.getLastSelectedPathComponent();
        DienDuLieuTable(Integer.valueOf(Stock.IdProduct(cn.toString())));
        String a = cn.toString();
        String a1 = Stock.IdProduct(a);
        String time = jTableHS.getValueAt(0, 0).toString();
        System.out.println(time);
        Label(a1, time);
    }//GEN-LAST:event_jTreeProductValueChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButtonPurchar;
    private javax.swing.JButton jButtonsale;
    private org.sourceforge.jcalendarbutton.JCalendarPopup jCalendarPopup1;
    private javax.swing.JComboBox jComboBoxMotnh;
    private javax.swing.JComboBox jComboBoxProduct;
    private javax.swing.JComboBox jComboBoxSelectTime;
    private javax.swing.JComboBox jComboBoxTotal;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JList jList4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabelSql;
    private javax.swing.JLabel jLabelsl;
    private javax.swing.JLabel jLabeltotalProduct;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel26;
    private javax.swing.JPanel jPanel27;
    private javax.swing.JPanel jPanel28;
    private javax.swing.JPanel jPanel29;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel36;
    private javax.swing.JPanel jPanel37;
    private javax.swing.JPanel jPanel38;
    private javax.swing.JPanel jPanel39;
    private javax.swing.JPanel jPanel40;
    private javax.swing.JPanel jPanel41;
    private javax.swing.JPanel jPanel42;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel67;
    private javax.swing.JPanel jPanel68;
    private javax.swing.JPanel jPanel69;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel70;
    private javax.swing.JPanel jPanel71;
    private javax.swing.JPanel jPanel72;
    private javax.swing.JPanel jPanel73;
    private javax.swing.JPanel jPanel74;
    private javax.swing.JPanel jPanel75;
    private javax.swing.JPanel jPanel76;
    private javax.swing.JPanel jPanel77;
    private javax.swing.JPanel jPanel78;
    private javax.swing.JPanel jPanel79;
    private javax.swing.JPanel jPanel80;
    private javax.swing.JPanel jPanel81;
    private javax.swing.JPanel jPanel82;
    private javax.swing.JPanel jPanel83;
    private javax.swing.JPanel jPanel84;
    private javax.swing.JPanel jPanel85;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTable jTable1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableHS;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTree jTreeProduct;
    // End of variables declaration//GEN-END:variables
}
